#include "DM.h"
#include "message.h"
#include <vector>
#include <queue>
#include <set>

//----------------------------------------------------------------------------------------------------------//
void Net_C::sortNodes()
{
    Node_C* pCurNode = this->_pFromNode;
    vector<Node_C*> vNode;
    queue<Node_C*> qPool;
    set<Node_C*> setNode;
    qPool.push(pCurNode);
    setNode.insert(pCurNode);
    while(1){
        pCurNode = qPool.front();
        DebugMsg("[Net][sortNodes] %s\n",pCurNode->getName().c_str());
        vNode.push_back(pCurNode);
        for(unsigned int iWire=0;iWire<pCurNode->getToWire().size();++iWire){
            Node_C* pToNode = pCurNode->getToWire()[iWire]->getToNode();
            if(0==setNode.count(pToNode)) {qPool.push(pToNode);}
        }
        qPool.pop();
        if(qPool.empty()) break;
    }
    this->_vNode = vNode;
}
//----------------------------------------------------------------------------------------------------------//



